package com.google.coffeeshop.entity;

import java.io.Serializable;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
@Entity
@Table(name="receipt_note_line")
public class ReceiptNoteLineDTO implements Serializable {

	private static final long serialVersionUID = 1L;
	
	@Id
	@Column(name = "id")
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Long id;
	@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.MERGE)
	@JoinColumn(name = "receipt_id", nullable = false)
	private ReceiptNoteDTO receiptNote;
	@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.MERGE)
	@JoinColumn(name = "product_id", nullable = false)
	private ProductDTO product;
	@Column(name="quantity")
	private Long quantity;
	@Column(name="unit_price")
	private Long priceOfUnit;

	@Override
	public String toString() {
		String receiptNoteId = "null";
		if (null != receiptNote && null != receiptNote.getId()) {
			receiptNoteId = receiptNote.getId().toString();
		}
		return String.format("id=%d, receipNoteId=%s", id, receiptNoteId);
	}
	
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public ReceiptNoteDTO getReceiptNote() {
		return receiptNote;
	}
	public void setReceiptNote(ReceiptNoteDTO receiptNote) {
		this.receiptNote = receiptNote;
	}
	public ProductDTO getProduct() {
		return product;
	}
	public void setProduct(ProductDTO product) {
		this.product = product;
	}
	public Long getQuantity() {
		return quantity;
	}
	public void setQuantity(Long quantity) {
		this.quantity = quantity;
	}
	public Long getPriceOfUnit() {
		return priceOfUnit;
	}
	public void setPriceOfUnit(Long price) {
		this.priceOfUnit = price;
	}
	
}
